# FROM centos:7 as webpackenv

# # 安装nodejs 环境
# RUN curl --silent --location https://rpm.nodesource.com/setup_12.x | bash -
# RUN yum -y install nodejs

# mengtoumingren/webpackenv:node12 是自定义的编译环境，tag node12为nodejs 12版本，可以用上面的指令自定义编译环境（比较耗时）
FROM mengtoumingren/webpackenv:node12 as buildenv

# FROM webpackenv:12 as buildenv

WORKDIR /
COPY package.json /
RUN npm install --registry=https://registry.npm.taobao.org


FROM buildenv as builder

COPY . /

RUN npm run build:prod

FROM nginx:latest as final

WORKDIR /usr/share/nginx/html/
COPY --from=builder  ./dist /usr/share/nginx/html/  
EXPOSE 80

RUN chmod u+x dockerinit.sh


ENTRYPOINT ["./dockerinit.sh"]



